package com.gis.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gis.entity.NodeData;
import com.gis.entity.ProcessData;
import com.gis.entity.ScriptData;

@Mapper
@Repository
public interface NodeMapper extends BaseMapper<NodeData> {
    
    @Results({
        @Result(column = "script_id", property = "script", one = @One(select = "com.gis.mapper.ScriptMapper.selectById")),
        @Result(column = "process_id", property = "process", one = @One(select = "com.gis.mapper.ProcessMapper.selectById"))
    })
    @Select("SELECT * FROM node_table WHERE id = #{id}")
    NodeData selectById(@Param("id") Long id);

    @Results({
        @Result(column = "script_id", property = "scriptId"),
        @Result(column = "process_id", property = "processId"),
        @Result(column = "script_id", property = "script", one = @One(select = "com.gis.mapper.ScriptMapper.selectById")),
        @Result(column = "process_id", property = "process", one = @One(select = "com.gis.mapper.ProcessMapper.selectById"))
    })
    @Select("SELECT * FROM node_table")
    List<NodeData> selectAllNode();

    @Results({
        @Result(column = "script_id", property = "scriptId"),
        @Result(column = "process_id", property = "processId"),
        @Result(column = "script_id", property = "script", one = @One(select = "com.gis.mapper.ScriptMapper.selectById"))
    })
    @Select("SELECT * FROM node_table WHERE process_id = #{process_id}")
    List<NodeData> selectByProcessId(@Param("process_id") Long process_id);
}
